<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>

<style type="text/css">

.photo
{
    margin-left:auto;
    margin-right:auto;
    margin-top:5px;
    width:160px;
    height:160px;
    overflow:hidden;
    background-color:#f8fdff;
    border:4px solid #f3f3f3;
    text-align:center;
    vertical-align:bottom;
    line-height:62px; 
    display:block;
}

.photoTitle
{
    margin-left:auto;
    margin-right:auto;
    display:table;
    padding-top:0px;
    
    *padding-left:15px;
    _padding-left:15px;
}
</style>
<script type="text/javascript" src="<%=path%>/include/FileUpload/fileUpload.js"></script>
<script type="text/javascript">
function delFile(preSavePath){
    //大照片的路径
	savePath = document.getElementById("myphoto").savePath;
    $.ajax({
		type: "POST", url: "<%=path%>/servlet/FileUploadManagerServlet?method=delImage&filePath="+savePath,
		data:$("#form1").serialize(),
		error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
		success: function(msg){
			//页面去除img的属性
			$("#myphoto").attr("src","");
			$("#myphoto").attr("savePath","");
		}
	});
	
	//小照片的路径
	smallPath = document.getElementById("myphoto").smallPath;
	if(smallPath!=""){
		$.ajax({
			type: "POST", url: "<%=path%>/servlet/FileUploadManagerServlet?method=delImage&filePath="+smallPath,
			data:$("#form1").serialize(),
			error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
			success: function(msg){
				//页面去除img的属性
				$("#myphoto").attr("src","");
				$("#myphoto").attr("smallPath","");
			}
		});
	}
 }


//上传组件参数初始化
//serverPath属性如果设置compress=true&width=168&height=200，则组件会按照这个尽寸对照片进行压缩
//serverPath属性如果设置compress=true，则组件会对图片按比例压缩，如果不设置compress属性，则不进行压缩
var setting={
	id:"FileUpload",
	swfPath:"<%=path%>/include/FileUpload/FileUploadForHr.swf",
	serverPath:"<%=path%>/servlet/FileUploadManagerServlet?method=savePhoto&compress=true&width=100&height=100",
	imgPath:"<%=path%>/include/FileUpload/uploadPhoto.jpg",
	width:90,
	height:20,
 	fileSize:"20",
	noFileType:"*.exe",
 	checkAndUploadExtend:checkAndUploadExtend,
 	uploadOnProgressExtend:uploadOnProgressExtend,
 	uploadCompleteExtend:uploadCompleteExtend
};


/*上传文件有效性判断*/
function checkAndUploadExtend(id,serverJson){

	//记录前一次上传的图片的url
	prePhotoSavePath = document.getElementById("myphoto").savePath;
    
	//如果你想获取当前上传组件参数的话
	//var parameters=FU.getSettingById[id];
	if(serverJson.checkType=="all"){
		//各种校验通过,如果你想在文件正式上传前做点什么的话，你就在这做吧！
		//alert("serverJson:"+serverJson);
		
		//$("#fileInfo").html(serverJson.fileName);
		//$("#json1").html(FU.jsonToStr(serverJson));
	}else if(serverJson.checkType=="suffix"){
		//文件后缀名有误
		alert("文件后缀名有误1");
	}else if(serverJson.checkType=="noSuffix"){
		//不允许的后缀名出错
		alert("不允许的后缀名有误1");
	}else if(serverJson.checkType=="size"){
		//文件大小有误
		alert("文件大小超过限制,请上传20以内的附件.");
	}
}

/*文件上传进度控制*/
function uploadOnProgressExtend(id,serverJson){
	var percentFormat=Math.floor(serverJson.percent*100);
	//$("#json2").html(FU.jsonToStr(serverJson));
	//$("#perspan").html(percentFormat+"%");
}

/*文件上传成功后，将服务器返回值返回到页面*/
function uploadCompleteExtend(id,serverJson){
	//如果你想在文件上传结束后做点什么的话，你就在这做吧！
	var imageObj = eval("("+serverJson+")");
	//alert("返回文件名："+imageObj.fileName);//返回文件名
	//alert("返回照片相对路径："+imageObj.imgPath);//返回照片相对路径
	//返回压缩后照片的相对路径,如果参数初始化setting中serverPath项设置了width和height,则后台会返回压缩后照片的相对路径
	//alert("返回压缩后照片的相对路径："+imageObj.smallImgPath);
	
	//页面读取大照片的url
	var imagurl = '<%=path%>/servlet/FileUploadManagerServlet?method=showImage&imgPath='+imageObj.imgPath;
	
	//也可以读取小照片的url
	var smallimag = '<%=path%>/servlet/FileUploadManagerServlet?method=showImage&imgPath='+imageObj.smallImgPath;
	
	$.ajax({
		type: "POST", url: '<%=path%>/regist/registservlet?method=savePhoto&personuuid=<%=personuuid%>&imgpath='+imageObj.imgPath+'&smallimgpath='+imageObj.smallImgPath,
		error:function(){alert("与服务器失去联系，请刷新本页面后再重试！");},
		success: function(msg){}
		});
	//设置img的src属性
	if(imageObj.smallImgPath!=""){
		$("#myphoto").attr("src",smallimag);
	}else{
		$("#myphoto").attr("src",imagurl);
	}
	
	//在页面记录大照片的路径,方便取消上传时从页面用ajax删除大照片
	$("#myphoto").attr("savePath",imageObj.imgPath);
	
	//在页面记录小照片的路径,方便取消上传时从页面用ajax删除小照片
	$("#myphoto").attr("smallPath",imageObj.smallImgPath);
	
}

function _changestatus(){
	var obj = document.getElementById("workstatus");
	$.ajax({
		type: "POST", url: '<%=path%>/regist/registservlet?method=changeStatus&personuuid=<%=personuuid%>&workstatus='+obj.value,
		error:function(){alert("无法完成修改状态操作，请稍后再试！");},
		success: function(msg){}
		});
}
</script>

        <sap:Person id="<%=personuuid%>">
        <table width="190" cellpadding="0" cellspacing="1" border="0" bgcolor="#dddddd">
        <tr>
        	<td>
            <table width="190" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF">
            <tr>
            	<td width="50%" colspan="2" align="left" class="blueBold12" style="margin-left:10px;">&nbsp;&nbsp;&nbsp;个人资料</td>
                <td align="right" width="50%" class="blueNormal12" style="margin-right:10px;">&nbsp;&nbsp;&nbsp;</td>
            </tr>
            <tr>
            	<td width="50%" colspan="3" align="center">
                <div id="carImageDiv" class="photo">
                    <span id="perspan"></span>
                    <input id="zhaopianurl" type="hidden" value="<sap:write property='PI_ZHAOPIAN' />">
                    <img id="myphoto" name="myphoto" savePath="" alt="" width="160" height="160" src="" style="border: 0px;" />
                    <script language="javascript">
					<!--
					function setzhaopianurl(){
						var obj = document.getElementById("zhaopianurl");
						var pobj = document.getElementById("myphoto");
						if(obj.value==""){
							pobj.src="<%=path%>/upload/user/nobody.gif";
						}else{
							pobj.src="<%=path%>/servlet/FileUploadManagerServlet?method=showImage&imgPath="+obj.value;
						}
					}
					setzhaopianurl();
					-->
					</script> 
                </div>
                <script>
				//调用上传组件
				FU.iniFlashPlayer(setting);
				</script>                </td>
            </tr>
            <tr>
            	<td colspan="4" align="center" class="lightBlueBold14">
                   	<sap:write property="PI_FIRSTNAME"/><sap:write property="PI_LASTNAME" />&nbsp;
                    <select id="workstatus" name="workstatus" onchange="javascript:_changestatus();">
                    	<option value="1">项目中</option>
                        <option value="2">项目快结束了</option>
                        <option value="3">休息中</option>
                        <option value="4">上岸了</option>
                        <option value="5">下海了</option>
                    </select></td>
            </tr>
            <tr><td height="10" colspan="3"></td></tr>
            <tr>
            	<td class="blackNormal12" align="right" width="20" height="20">&nbsp;&nbsp;&nbsp;</td>
                <td class="blackNormal12" align="left" nowrap="nowrap">威望：<sap:write property="PI_WEIWANG" /></td>
                <td class="blackNormal12" align="left">财富：<sap:write property="PI_CAIFU" /></td>
            </tr>
            <tr>
            	<td class="blackNormal12" align="right" width="20" height="20">&nbsp;&nbsp;&nbsp;</td>
                <td class="blackNormal12" align="left" nowrap="nowrap">自己人：<sap:write property="PI_HAOYOU" /></td>
                <td class="blackNormal12" align="left">徒弟：<sap:write property="PI_RENQI" /></td>
            </tr>
            
            <!--tr>
            	<td class="greyNormal12" colspan="2" align="center">好友（<sap:write property="PI_HAOYOU" />）&nbsp;&nbsp;关注（<sap:write property="PI_GUANZHU" />）</td>
            </tr-->
            
            <tr>
            	<td colspan="3" align="center" height="10" valign="middle"><div style="border-top:1px dashed #cccccc;height: 1px;overflow:hidden; width:160px;"></div></td>
            </tr>
            
            <tr>
                <td colspan="3">
                <%
                net.sapfree.user.vo.UserVO uservo = (net.sapfree.user.vo.UserVO)request.getSession(false).getAttribute("uservo");
                net.sapfree.core.db.RecordSet recordmodule = null;
                if(uservo!=null){
                    recordmodule = uservo.getModule();
                }
                %>
            
                <!--业务模块经验-->
                <table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="#FFFFFF">
                    <%
                    if(recordmodule!=null){
                        float freeyear = 0;
                        float waibuyear = 0;
                        float neibuyear = 0;
                        for(int mc=0;mc<recordmodule.size();mc++){
                            net.sapfree.core.db.Record module = recordmodule.get(mc);
                            
                            freeyear = Float.valueOf(module.getString("PPM_FREE","0")).floatValue();
                            waibuyear = Float.valueOf(module.getString("PPM_WAIBU","0")).floatValue();
                            neibuyear = Float.valueOf(module.getString("PPM_NEIBU","0")).floatValue();
                    %>
                            <tr>
                                <td width="20">&nbsp;</td>
                                <td width="50" class="greyNormal12"><%=module.getString("PPM_MODULENAME")%></td>
                                <td class="blackBold12"><%=freeyear+waibuyear+neibuyear%>年</td>
                            </tr>
                    <%
                        }
                    }
                    %>
                </table>                </td>
            </tr>
            </table>
            
            </td>
        </tr>
        </table>
		</sap:Person>
        
